//导入

var homehref = '';
$(function(){
    Page.initCss();
    Page.key = urls.GetQueryString('key');
    Page.id = urls.GetQueryString('mkey');
    // Page.parent_id = urls.GetQueryString('parentId');
    // Page.parent_name = urls.GetQueryString('parentName');
    // Page.name = urls.GetQueryString('name');

    if(Page.id) {
        Page.loadData();
    }
    

    var url_param = '?key=' + Page.key + '&mkey=' + Page.id;
    $('.tab-zongshu').attr('href', '../zongshu/' + url_param);
    $('.tab-pingfen').attr('href', '../pingfen/'  + url_param);
});

var Page = {
    id: false,
    name: false,
    parent_id: false,
    parent_name: false
};

Page.initCss = function() {
    var bodyWidth = Page.getWindowWidth();
    var bodyHeight = Page.getWindowHeight();
    $('.w-rest-160').width(bodyWidth - 180);
    // $('.param').css({'min-height': (bodyHeight - 360)+'px'})
}

Page.loadData = function() {
    var url = urls.server + '/models/' + Page.id + '/mdetails';
    $.ajax({
        type: 'GET',
        async: true,
        url: url,
        dataType: 'json',
        success: function(e){
            if(!e || e.length < 1) {
                return;
            }
            var h = '';
            /*for(var i=0, len=e.length; i<len; i++) {
                var item = e[i];
                if(i<4) {
                    h += '<tr>';
                    h += '  <td class="lbl">'+ item.name_cn +'</td>';
                    h += '  <td>'+ item.item_value +'</td>';
                    h += '<tr>';        
                }
                else {
                    h1 += '<tr>';
                    h1 += '  <td class="lbl">'+ item.name_cn +'</td>';
                    h1 += '  <td>'+ item.item_value +'</td>';
                    h1 += '<tr>';    
                }
            }*/


            for(var i=0, len=e.length; i<len; i++) {
                var item = e[i];
                h += '<tr class="thead"><td colspan="2">'+ item.mtitle +'</td></tr>';
                for( var k=0, ll=item.sub_param.length; k<ll; k++) {
                    var m = item.sub_param[k];
                    h += '<tr>';
                    h += '  <td class="lbl">'+ m.item_cn +'</td>';
                    h += '  <td>'+ m.item_value +'</td>';
                    h += '<tr>';
                } 
            }
            $('.table-peizhi').html(h);
            
        }
    });
}









//获取页面显示区域高度
Page.getWindowHeight = function() {
    if (navigator.appName == "Microsoft Internet Explorer" ) {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientHeight : document.body.clientHeight;
    }
    else {
        return self.innerHeight;
    } 
}

//获取页面显示区域宽度
Page.getWindowWidth = function() {
    if (navigator.appName == "Microsoft Internet Explorer") {
        return document.compatMode == "CSS1Compat" ? document.documentElement.clientWidth : document.body.clientWidth;
    }
    else {
        return self.innerWidth;
    } 
}

